﻿using System;
using System.Collections.Generic;
using System.Text;
using WebApiV2.Data.Model;
using WebApiV2.Domain.Enum;
using WebApiV2.Interface.Log;

namespace WebApiV2.Utils
{
     public static class LogHelper
    {
        //ILong包装
        public static void Logger(this ILog log, Exception exception, LogsLever logsLever , int userId) 
        { 
            var item = new Logs
            {
                LogLevel = (int)logsLever,
                ShortMessage = exception.Message,
                FullMessage = exception.ToString(),
                UserId = userId,
            };
            log.Insert(item);
        }

        public static void Info(this ILog log, Exception exception, LogsLever logsLever = LogsLever.信息, int userId= 0)
       {
            Logger(log,exception,logsLever,userId);
        }
        public static void Dabug(this ILog log, Exception exception, LogsLever logsLever = LogsLever.调试, int userId=0)
        {
            Logger(log, exception, logsLever, userId);
        }

        public static void Error(this ILog log, Exception exception, LogsLever logsLever = LogsLever.错误, int userId = 0)
        {
            Logger(log, exception, logsLever, userId);
        }
        public static void Fatal(this ILog log, Exception exception, LogsLever logsLever = LogsLever.崩溃, int userId = 0)
        {
            Logger(log, exception, logsLever, userId);
        }
    }
}
